﻿using DataAccess;
using DTO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAO
{
    public class ChucVuDAO
    {
        public static DataTable ChucVu(int machucvu)
        {
            string query = "SELECT MaChucVu,TenChucVu FROM  CHUCVU where MaChucVu='"+ machucvu +"'";
            DataTable dt = DataConnection.ExecQuery(query);
            return dt;
        }

        public static List<ChucVuDTO> LoadChucVu()
        {
            List<ChucVuDTO> list = new List<ChucVuDTO>();
            string query = "SELECT * FROM  CHUCVU ";
            DataTable dt = DataConnection.ExecQuery(query);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    ChucVuDTO dl = new ChucVuDTO();
                    dl.MaChucVu = dr["MaChucVu"].GetHashCode();
                    dl.TenChucVu = dr["TenChucVu"].ToString();
                    list.Add(dl);
                }
            }
            return list;
        }
    }
}
